package patrol.mobile.com.mobilepatrol.activity.toll;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.BaseActivity;
import patrol.mobile.com.mobilepatrol.api.Urls;
import patrol.mobile.com.mobilepatrol.bean.JobEvaluationInformationBean;
import patrol.mobile.com.mobilepatrol.utils.CommonUtil;
import patrol.mobile.com.mobilepatrol.utils.GsonUtil;
import patrol.mobile.com.mobilepatrol.utils.net.HttpCallBack2;
import patrol.mobile.com.mobilepatrol.utils.net.HttpSender;

/**
 * 岗位考核信息
 */
public class JobEvaluationInformationActivity extends BaseActivity {

    @BindView(R.id.tv_address)
    TextView tvAddress;
    @BindView(R.id.tv_time)
    TextView tvTime;
    @BindView(R.id.tv_current_address)
    TextView tvCurrentAddress;
    @BindView(R.id.rl_kaohegangwei)
    RelativeLayout rlKaohegangwei;
    @BindView(R.id.tv_exam)
    TextView tvExam;
    @BindView(R.id.rl_beikaoheren)
    RelativeLayout rlBeikaoheren;
    @BindView(R.id.tv_exam_name)
    TextView tvExamName;
    @BindView(R.id.tv_current_banci)
    TextView tvCurrentBanci;
    @BindView(R.id.btn_next)
    Button btnNext;
    private String id = "";
    public static final String JOB_ID = "JOB_ID";
    private JobEvaluationInformationBean bean;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_job_evaluation_information;
    }

    @Override
    public void initView() {
        super.initView();
        iv_back.setImageResource(R.mipmap.up_white);
        iv_back.setVisibility(View.VISIBLE);
        iv_back.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        CommonUtil.exitActivityAndBackAnim(JobEvaluationInformationActivity.this, true);
                    }
                });
        tv_center_title.setVisibility(View.VISIBLE);
        tv_center_title.setText("岗位考核信息");
    }

    @Override
    public void initData() {
        super.initData();
        id = getIntent().getStringExtra(JOB_ID);
        HttpSender sender = new HttpSender(this, baseUrl, Urls.GET_ORG_POST_ENTITY);
        HashMap<String, String> map = new HashMap<>();
        map.put("id", this.id);
        sender.requestPost(map, new HttpCallBack2(sender) {
            @Override
            public void onError(String code, Call call, Exception e) {

            }

            @Override
            public void onResponse(String code, String response, String attachList) {
//                bean = GsonUtil.GsonToBean(response, JobEvaluationInformationBean.class);
                Log.i("0", "onResponse: ");
                bean = new Gson().fromJson(response, JobEvaluationInformationBean.class);
                Log.i("1111111", "onResponse: "+bean.getCheckName());
                tvAddress.setText(bean.getOrgName());
                tvTime.setText(bean.getMouthDate());
                tvCurrentAddress.setText(JobEvaluationInformationActivity.this.bean.getAssessmentPost());
                tvExam.setText(JobEvaluationInformationActivity.this.bean.getCheckName());
                tvExamName.setText(JobEvaluationInformationActivity.this.bean.getAssessor());
                tvCurrentBanci.setText(JobEvaluationInformationActivity.this.bean.getPeriod());
            }
        });
    }

    @Override
    public void setListener() {

    }

    @OnClick({R.id.rl_kaohegangwei, R.id.rl_beikaoheren, R.id.btn_next})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_kaohegangwei:
                break;
            case R.id.rl_beikaoheren:
                break;
            case R.id.btn_next:
                if (bean == null) return;
                Intent intent = new Intent(JobEvaluationInformationActivity.this, EvaluationDetail2Activity.class);
                intent.putExtra("list", bean);
                startActivity(intent);
                break;
        }
    }
}
